import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;


public class DirectArrayAccess {
	private static Map<String,String> idMap = new LinkedHashMap<String,String>();
	
	public static void readFile(String fileName){
		FileInputStream fis = null;
		FileChannel fc = null;
		int fillSize=0;
		byte[] keyBuf = new byte[32];
		byte[] commaBuf = new byte[1];
		byte[] valueBuf = new byte[32];
		byte[] newLineBuf = new byte[1];
		ByteBuffer byteBuf = ByteBuffer.allocate(1024*1024*50); 
		try{
			
			fis = new FileInputStream(new File(fileName));
			fc = fis.getChannel();
			int bytesRead = fc.read(byteBuf);
			fis.read(keyBuf);
			fis.read(commaBuf);
			fis.read(valueBuf);
			fis.read(newLineBuf);
			while(bytesRead != -1){	
				byteBuf.flip();
				
				while(byteBuf.remaining() >= 66){
					
					for(String key : idMap.keySet()){
						if(arrayEquals(keyBuf,key.getBytes())){
							idMap.put(key, new String(valueBuf).trim());
							fillSize++;
						}
						if(arrayEquals(valueBuf,key.getBytes())){
							idMap.put(key, new String(keyBuf).trim());
							fillSize++;
						}
					}
					if(fillSize == idMap.size()){
						break;
					}
					bytesRead = fis.read(keyBuf);
					fis.read(commaBuf);
					fis.read(valueBuf);
					fis.read(newLineBuf);
			}
		}
			
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			try {
				fis.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public static boolean arrayEquals(byte[] line,byte[]key){
		return Arrays.equals(line, key);
	}
	public static void main(String[] args) {
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		char[] cbuf ; 
		// This is just a demo. You can use any logic here to read from stdin - till End of File or End of Stream etc.,
		cbuf = new char[1024] ;
		try {
			in.read(cbuf)  ;
		} catch (IOException e) {
			e.printStackTrace();
		}	finally	{
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		String inputs = new String(cbuf);
		args = inputs.split(" ");
		if(args == null) {
			System.out.print("FAILURE");
			System.exit(1);
		}
		if(args.length == 1) {
			File f = new File(args[0].trim());
			if(f.exists()){
				readFile(args[0].trim());
				System.out.print("READY");
				System.exit(0);
			}	else	{
				System.out.print("FAILURE");
				System.exit(1);
			}			
		}
		
		for (int i = 1; i < args.length; i++) {
			String arg = args[i].trim();
			if(arg.contains("T=") || arg.contains("R=")){
				String ids = arg.substring(arg.indexOf("=")+1);
				String[] idArr = ids.split(",");
				for (int j = 0; j < idArr.length; j++) {
					idMap.put(idArr[j], null);
				}
			}
		}
		readFile(args[0].trim());
		List<String> values = new ArrayList<String>(idMap.values());
		for (int i = 0; i < values.size(); i++) {
			String value = values.get(i);
			if(value == null){
				value = "FAILURE";
			}
			System.out.print(value);
			if((i +1) < values.size())	{
				System.out.print(",");
			}				
		}
	}
}
//C:\\sivravis\\dev\\studies\\BOC2014\\codeContest1M.csv
//C:\sivravis\dev\studies\BOC2014\codeContest1M.csv
//C:\\sivravis\\dev\\studies\\BOC2014\\sampleInput.csv T=TXN00000000000000043179168899325,TXN00000000000000050209776656593 R=REF00000000000000116009591331268
//C:\\sivravis\\dev\\studies\\BOC2014\\codeContest1M.csv T=TXN00000000000000038017647990705,TXN00000000000000187337910501133 R=REF00000000000000269582048411792,REF00000000000000242906007369522
//C:\\sivravis\\dev\\studies\\BOC2014\\codeContest10M.csv T=TXN00000000000000038017647990705,TXN00000000000000187337910501133 R=REF00000000000000269582048411792,REF00000000000000242906007369522
//C:\\sivravis\\dev\\studies\\BOC2014\\codeContest1M.csv T=TXN00000000000000208894155973619 R=REF00000000000000037551152931374